<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Bounce2: Debouncer Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Bounce2
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="class_debouncer-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Debouncer Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div>  </div>
</div><!--header-->
<div class="contents">

<p>The Debouce class. Just the deboucing code separated from all harware.  
 <a href="class_debouncer.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_bounce2_8h_source.html">Bounce2.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for Debouncer:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_debouncer.png" usemap="#Debouncer_map" alt=""/>
  <map id="Debouncer_map" name="Debouncer_map">
<area href="class_bounce.html" title="The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. This class is odly named,..." alt="Bounce" shape="rect" coords="0,56,103,80"/>
<area href="class_bounce2_1_1_button.html" alt="Bounce2::Button" shape="rect" coords="0,112,103,136"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a34c46ca04d4178933cc0049436d10fe6"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#a34c46ca04d4178933cc0049436d10fe6">Debouncer</a> ()</td></tr>
<tr class="memdesc:a34c46ca04d4178933cc0049436d10fe6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create an instance of the Debounce class.  <a href="class_debouncer.html#a34c46ca04d4178933cc0049436d10fe6">More...</a><br /></td></tr>
<tr class="separator:a34c46ca04d4178933cc0049436d10fe6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a930bf3945e698d77b889f6309079857d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#a930bf3945e698d77b889f6309079857d">interval</a> (uint16_t interval_millis)</td></tr>
<tr class="memdesc:a930bf3945e698d77b889f6309079857d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the debounce interval in milliseconds.  <a href="class_debouncer.html#a930bf3945e698d77b889f6309079857d">More...</a><br /></td></tr>
<tr class="separator:a930bf3945e698d77b889f6309079857d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a72f3e8d483555031d2ac21b0b7702c06"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#a72f3e8d483555031d2ac21b0b7702c06">update</a> ()</td></tr>
<tr class="memdesc:a72f3e8d483555031d2ac21b0b7702c06"><td class="mdescLeft">&#160;</td><td class="mdescRight">Updates the pin's state.  <a href="class_debouncer.html#a72f3e8d483555031d2ac21b0b7702c06">More...</a><br /></td></tr>
<tr class="separator:a72f3e8d483555031d2ac21b0b7702c06"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa5fcde9156f700c362fd49af5dd92ecd"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#aa5fcde9156f700c362fd49af5dd92ecd">read</a> () const</td></tr>
<tr class="memdesc:aa5fcde9156f700c362fd49af5dd92ecd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the pin's state (HIGH or LOW).  <a href="class_debouncer.html#aa5fcde9156f700c362fd49af5dd92ecd">More...</a><br /></td></tr>
<tr class="separator:aa5fcde9156f700c362fd49af5dd92ecd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a80315de311b855f9787b4b6d5b7899e0"><td class="memItemLeft" align="right" valign="top"><a id="a80315de311b855f9787b4b6d5b7899e0"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#a80315de311b855f9787b4b6d5b7899e0">fell</a> () const</td></tr>
<tr class="memdesc:a80315de311b855f9787b4b6d5b7899e0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if pin signal transitions from high to low. <br /></td></tr>
<tr class="separator:a80315de311b855f9787b4b6d5b7899e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab61244e043754ebdc7a156da1e1824bf"><td class="memItemLeft" align="right" valign="top"><a id="ab61244e043754ebdc7a156da1e1824bf"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#ab61244e043754ebdc7a156da1e1824bf">rose</a> () const</td></tr>
<tr class="memdesc:ab61244e043754ebdc7a156da1e1824bf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if pin signal transitions from low to high. <br /></td></tr>
<tr class="separator:ab61244e043754ebdc7a156da1e1824bf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1bbd627f9d8809b5ee9e64e9fb21e248"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#a1bbd627f9d8809b5ee9e64e9fb21e248">changed</a> () const</td></tr>
<tr class="memdesc:a1bbd627f9d8809b5ee9e64e9fb21e248"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if the state changed on last update.  <a href="class_debouncer.html#a1bbd627f9d8809b5ee9e64e9fb21e248">More...</a><br /></td></tr>
<tr class="separator:a1bbd627f9d8809b5ee9e64e9fb21e248"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a883645ca26b4df6e5823586432104d11"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#a883645ca26b4df6e5823586432104d11">currentDuration</a> () const</td></tr>
<tr class="memdesc:a883645ca26b4df6e5823586432104d11"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the duration in milliseconds of the current state.  <a href="class_debouncer.html#a883645ca26b4df6e5823586432104d11">More...</a><br /></td></tr>
<tr class="separator:a883645ca26b4df6e5823586432104d11"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac6af22dc9c6ae84462fe356b7430659e"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#ac6af22dc9c6ae84462fe356b7430659e">previousDuration</a> () const</td></tr>
<tr class="memdesc:ac6af22dc9c6ae84462fe356b7430659e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the duration in milliseconds of the previous state.  <a href="class_debouncer.html#ac6af22dc9c6ae84462fe356b7430659e">More...</a><br /></td></tr>
<tr class="separator:ac6af22dc9c6ae84462fe356b7430659e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a462994f1f9a20876b2ee239eeee97448"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_debouncer.html#a462994f1f9a20876b2ee239eeee97448">duration</a> ()</td></tr>
<tr class="memdesc:a462994f1f9a20876b2ee239eeee97448"><td class="mdescLeft">&#160;</td><td class="mdescRight">DEPRECATED (i.e. do not use). Renamed <a class="el" href="class_debouncer.html#a883645ca26b4df6e5823586432104d11" title="Returns the duration in milliseconds of the current state.">currentDuration()</a>.  <a href="class_debouncer.html#a462994f1f9a20876b2ee239eeee97448">More...</a><br /></td></tr>
<tr class="separator:a462994f1f9a20876b2ee239eeee97448"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a38f85f1c1819a5634d93565e0459117b"><td class="memItemLeft" align="right" valign="top"><a id="a38f85f1c1819a5634d93565e0459117b"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>begin</b> ()</td></tr>
<tr class="separator:a38f85f1c1819a5634d93565e0459117b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4a377599ec41b901d6a291809c60eb4f"><td class="memItemLeft" align="right" valign="top"><a id="a4a377599ec41b901d6a291809c60eb4f"></a>
virtual bool&#160;</td><td class="memItemRight" valign="bottom"><b>readCurrentState</b> ()=0</td></tr>
<tr class="separator:a4a377599ec41b901d6a291809c60eb4f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr class="memitem:afab369aec42a15595ebac695a088cccd"><td class="memItemLeft" align="right" valign="top"><a id="afab369aec42a15595ebac695a088cccd"></a>
unsigned long&#160;</td><td class="memItemRight" valign="bottom"><b>previous_millis</b></td></tr>
<tr class="separator:afab369aec42a15595ebac695a088cccd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a25f000f08b3291f80154ec620abfe52a"><td class="memItemLeft" align="right" valign="top"><a id="a25f000f08b3291f80154ec620abfe52a"></a>
uint16_t&#160;</td><td class="memItemRight" valign="bottom"><b>interval_millis</b></td></tr>
<tr class="separator:a25f000f08b3291f80154ec620abfe52a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a50b7f921222452bf7328ad84d09c15af"><td class="memItemLeft" align="right" valign="top"><a id="a50b7f921222452bf7328ad84d09c15af"></a>
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><b>state</b></td></tr>
<tr class="separator:a50b7f921222452bf7328ad84d09c15af"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1bcf1b5c2a67b6409fea2e8705bcab57"><td class="memItemLeft" align="right" valign="top"><a id="a1bcf1b5c2a67b6409fea2e8705bcab57"></a>
unsigned long&#160;</td><td class="memItemRight" valign="bottom"><b>stateChangeLastTime</b></td></tr>
<tr class="separator:a1bcf1b5c2a67b6409fea2e8705bcab57"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adbe8de6a1cfff329629e9136a4efea6c"><td class="memItemLeft" align="right" valign="top"><a id="adbe8de6a1cfff329629e9136a4efea6c"></a>
unsigned long&#160;</td><td class="memItemRight" valign="bottom"><b>durationOfPreviousState</b></td></tr>
<tr class="separator:adbe8de6a1cfff329629e9136a4efea6c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The Debouce class. Just the deboucing code separated from all harware. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a34c46ca04d4178933cc0049436d10fe6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a34c46ca04d4178933cc0049436d10fe6">&#9670;&nbsp;</a></span>Debouncer()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Debouncer::Debouncer </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create an instance of the Debounce class. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a1bbd627f9d8809b5ee9e64e9fb21e248"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1bbd627f9d8809b5ee9e64e9fb21e248">&#9670;&nbsp;</a></span>changed()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Debouncer::changed </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns true if the state changed on last update. </p>
<dl class="section return"><dt>Returns</dt><dd>True if the state changed on last update. Otherwise, returns false. </dd></dl>

</div>
</div>
<a id="a883645ca26b4df6e5823586432104d11"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a883645ca26b4df6e5823586432104d11">&#9670;&nbsp;</a></span>currentDuration()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long Debouncer::currentDuration </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the duration in milliseconds of the current state. </p>
<p>Is reset to 0 once the pin rises ( <a class="el" href="class_debouncer.html#ab61244e043754ebdc7a156da1e1824bf" title="Returns true if pin signal transitions from low to high.">rose()</a> ) or falls ( <a class="el" href="class_debouncer.html#a80315de311b855f9787b4b6d5b7899e0" title="Returns true if pin signal transitions from high to low.">fell()</a> ).</p>
<dl class="section return"><dt>Returns</dt><dd>The duration in milliseconds (unsigned long) of the current state. </dd></dl>

</div>
</div>
<a id="a462994f1f9a20876b2ee239eeee97448"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a462994f1f9a20876b2ee239eeee97448">&#9670;&nbsp;</a></span>duration()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long Debouncer::duration </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>DEPRECATED (i.e. do not use). Renamed <a class="el" href="class_debouncer.html#a883645ca26b4df6e5823586432104d11" title="Returns the duration in milliseconds of the current state.">currentDuration()</a>. </p>
<p>This member function is DEPRECATED will be removed next major version. DO NOT USE IT. USE <a class="el" href="class_debouncer.html#a883645ca26b4df6e5823586432104d11" title="Returns the duration in milliseconds of the current state.">currentDuration()</a> INSTEAD. It was renamed to avoid confusion with <a class="el" href="class_debouncer.html#ac6af22dc9c6ae84462fe356b7430659e" title="Returns the duration in milliseconds of the previous state.">previousDuration()</a>.</p>
<dl class="section return"><dt>Returns</dt><dd>The duration in milliseconds (unsigned long) of the current state. </dd></dl>

</div>
</div>
<a id="a930bf3945e698d77b889f6309079857d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a930bf3945e698d77b889f6309079857d">&#9670;&nbsp;</a></span>interval()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Debouncer::interval </td>
          <td>(</td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>interval_millis</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets the debounce interval in milliseconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">interval_millis</td><td>The interval time in milliseconds. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ac6af22dc9c6ae84462fe356b7430659e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac6af22dc9c6ae84462fe356b7430659e">&#9670;&nbsp;</a></span>previousDuration()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long Debouncer::previousDuration </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the duration in milliseconds of the previous state. </p>
<p>Takes the values of <a class="el" href="class_debouncer.html#a462994f1f9a20876b2ee239eeee97448" title="DEPRECATED (i.e. do not use). Renamed currentDuration().">duration()</a> once the pin changes state.</p>
<dl class="section return"><dt>Returns</dt><dd>The duration in milliseconds (unsigned long) of the previous state. </dd></dl>

</div>
</div>
<a id="aa5fcde9156f700c362fd49af5dd92ecd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa5fcde9156f700c362fd49af5dd92ecd">&#9670;&nbsp;</a></span>read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Debouncer::read </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the pin's state (HIGH or LOW). </p>
<dl class="section return"><dt>Returns</dt><dd>HIGH or LOW. </dd></dl>

</div>
</div>
<a id="a72f3e8d483555031d2ac21b0b7702c06"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a72f3e8d483555031d2ac21b0b7702c06">&#9670;&nbsp;</a></span>update()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Debouncer::update </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Updates the pin's state. </p>
<p>Because <a class="el" href="class_bounce.html" title="The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. This class is odly named,...">Bounce</a> does not use interrupts, you have to "update" the object before reading its value and it has to be done as often as possible (that means to include it in your loop()). Only call <a class="el" href="class_debouncer.html#a72f3e8d483555031d2ac21b0b7702c06" title="Updates the pin&#39;s state.">update()</a> once per loop().</p>
<dl class="section return"><dt>Returns</dt><dd>True if the pin changed state. </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>src/<a class="el" href="_bounce2_8h_source.html">Bounce2.h</a></li>
<li>src/Bounce2.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
